package com.loja.util;


import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;

import com.loja.instrumento.model.Cliente;
import com.loja.instrumento.model.Instrumento;



public class HibernateUtil {

   
            // Create the SessionFactory from hibernate.cfg.xml
 
    private static SessionFactory sessionFactory;  
    private static ServiceRegistry serviceRegistry;  
      
 
   static{
    	    Configuration configuration = new Configuration();
    	    configuration.configure();
    	    serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();        
    	    sessionFactory = configuration.buildSessionFactory(serviceRegistry);
    	   
    	}
    
      

    public static Session openSession() {       
    	 return sessionFactory.openSession();
    
    }

}